package io.renren.modules.stock.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Objects;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.stock.dao.LimitUpDao;
import io.renren.modules.stock.entity.LimitUpEntity;
import io.renren.modules.stock.service.LimitUpService;


@Service("limitUpService")
public class LimitUpServiceImpl extends ServiceImpl<LimitUpDao, LimitUpEntity> implements LimitUpService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<LimitUpEntity> limitUpEntityQueryWrapper = new QueryWrapper<>();
        Object key = params.get("key");
        if (Objects.nonNull(key)) {
            limitUpEntityQueryWrapper.like("concept", key)
                .or().like("surge_reason", key)
                .or().like("hot_topic", key);
        }
        IPage<LimitUpEntity> page = this.page(
                new Query<LimitUpEntity>().getPage(params),
            limitUpEntityQueryWrapper
        );

        return new PageUtils(page);
    }

}